'Generado con Version de GenCode 6.1.0.0
'Templates Version 6.1

Imports Owner.Framework.Data
Imports Owner.Framework.Data.DataFunctions
imports System.Data

Namespace Tafi.Hermes.Business
  Partial Public Class SV_DETALLESOLICITUDESBC

    Public Function GetByContrato(ByVal pDS_CONTRATO As Long) As DataTable
      Dim args As QueryArgs
      Try
        args = New QueryArgs
        args.ProcedureName = "SV_DETALLESOLICITUDESGetByCon"
        args.Parameters.Add("pDS_CONTRATO", pDS_CONTRATO)

        Return ExecuteDataTable(args)
      Finally
        args = Nothing
      End Try
    End Function

    Public Function GetByTicket(ByVal pSXT_TICKET As Long) As SV_DETALLESOLICITUDESCompleteList
      Dim args As QueryArgs
      Try
        args = New QueryArgs
        args.ProcedureName = "SV_DETALLESOLICITUDESGetByTkt"
        args.Parameters.Add("pSXT_TICKET", pSXT_TICKET)

        Return GetSV_DETALLESOLICITUDESListComplete(args)
      Finally
        args = Nothing
      End Try
    End Function

    Public Function GetDataTableByTicket(ByVal pSXT_TICKET As Long) As DataTable
      Dim args As QueryArgs
      Try
        args = New QueryArgs
        args.ProcedureName = "SV_DETALLESOLICITUDESGetByTkt"
        args.Parameters.Add("pSXT_TICKET", pSXT_TICKET)

        Return ExecuteDataTable(args)
      Finally
        args = Nothing
      End Try
    End Function

    Public Function GetOne(ByVal DS_NUMERO As System.Int64) As SV_DETALLESOLICITUDESList
      Dim args As QueryArgs
      Try
        args = New QueryArgs
        args.ProcedureName = "SV_DETALLESOLICITUDESGetOne"

        args.Parameters.Add("DS_NUMERO", DS_NUMERO)

        Return GetSV_DETALLESOLICITUDESList(args)
      Finally
        args = Nothing
      End Try
    End Function

        Public Function AddOne(ByVal obj As SV_DETALLESOLICITUDES) As Long
            Dim args As QueryArgs
            Dim oDT As DataTable
            Try
                args = New QueryArgs

                args.ProcedureName = "SV_DETALLESOLICITUDESAddOne"

                With obj
                    args.Parameters.Add("pDS_CONTRATO", .DS_CONTRATO)
                    args.Parameters.Add("pDS_SOLICITUD", .DS_SOLICITUD)
                    args.Parameters.Add("pDS_FECHA", .DS_FECHA)
                    args.Parameters.Add("pDS_OBSERV", .DS_OBSERV)
                    args.Parameters.Add("pDS_ESTADO", .DS_ESTADO)
                    args.Parameters.Add("pDS_UserId", .DS_UserId)
                End With

                oDT = ExecuteDataTable(args)

                Return oDT.Rows(0)(0)
            Finally
                oDT = Nothing
                args = Nothing
            End Try
        End Function

    Public Sub SolicitudComplete(ByVal pDS_NUMERO As Long, ByVal pDS_ESTADO As Integer)
      Dim args As QueryArgs
      Try
        args = New QueryArgs

        args.ProcedureName = "SV_DETALLESOLICITUDESComplete"

        args.Parameters.Add("pDS_NUMERO", pDS_NUMERO)
        args.Parameters.Add("pDS_ESTADO", pDS_ESTADO)

        ExecuteNonQuery(args)
      Finally
        args = Nothing
      End Try
    End Sub

    Public Sub DeleteByContrato(ByVal pDS_CONTRATO As System.Int64)
      Dim Args As QueryArgs
      Try
        Args = New QueryArgs
        Args.ProcedureName = "SV_DETALLESOLICITUDESDeleteByCon"

        Args.Parameters.Add("pDS_CONTRATO", pDS_CONTRATO)

        ExecuteNonQuery(Args)
      Finally
        Args = Nothing
      End Try
    End Sub

    Private Function GetSV_DETALLESOLICITUDESList(ByVal Args As QueryArgs) As SV_DETALLESOLICITUDESList
      Dim Tabla As DataTable
      Dim objFila As DataRow
      Dim objList As SV_DETALLESOLICITUDESList
      Try
        objList = New SV_DETALLESOLICITUDESList

        Tabla = ExecuteDataTable(Args)

        For Each objFila In Tabla.Rows
          objList.Add(SV_DETALLESOLICITUDESMapper(objFila))
        Next

        Return objList
      Catch ex As Exception
        Throw ex
      Finally
        Tabla = Nothing
        objList = Nothing
      End Try
    End Function

    Private Function SV_DETALLESOLICITUDESMapper(ByVal Fila As DataRow) As SV_DETALLESOLICITUDES
      Dim obj As SV_DETALLESOLICITUDES
      Try
        obj = New SV_DETALLESOLICITUDES
        With obj
          .DS_NUMERO = DbNullToInt32(Fila, "DS_NUMERO")
          .DS_CONTRATO = DbNullToInt32(Fila, "DS_CONTRATO")
          .DS_SOLICITUD = DbNullToInt32(Fila, "DS_SOLICITUD")
          .DS_FECHA = DbNullToDateTime(Fila, "DS_FECHA")
          .DS_OBSERV = DbNullToString(Fila, "DS_OBSERV")
          .DS_ESTADO = DbNullToInt32(Fila, "DS_ESTADO")
        End With
        Return obj
      Catch ex As Exception
        Throw ex
      Finally
        obj = Nothing
      End Try
    End Function

#Region "Mapper de Complete"
    Private Function GetSV_DETALLESOLICITUDESListComplete(ByVal Args As QueryArgs) As SV_DETALLESOLICITUDESCompleteList
      Dim Tabla As DataTable
      Dim objFila As DataRow
      Dim objList As SV_DETALLESOLICITUDESCompleteList
      Try
        objList = New SV_DETALLESOLICITUDESCompleteList

        Tabla = ExecuteDataTable(Args)

        For Each objFila In Tabla.Rows
                    ' objList.Add(SV_DETALLESOLICITUDESMapperComplete(objFila))
        Next

        Return objList
      Catch ex As Exception
        Throw ex
      Finally
        Tabla = Nothing
        objList = Nothing
      End Try
    End Function

        'Private Function SV_DETALLESOLICITUDESMapperComplete(ByVal Fila As DataRow) As SV_DETALLESOLICITUDESComplete
        '  Dim obj As SV_DETALLESOLICITUDESComplete
        '  Try
        '    obj = New SV_DETALLESOLICITUDESComplete
        '    With obj
        '      .DS_NUMERO = DbNullToInt32(Fila, "DS_NUMERO")
        '      .DS_CONTRATO = DbNullToInt32(Fila, "DS_CONTRATO")
        '      .DS_SOLICITUD = DbNullToInt32(Fila, "DS_SOLICITUD")
        '      .DS_FECHA = DbNullToDateTime(Fila, "DS_FECHA")
        '      .DS_OBSERV = DbNullToString(Fila, "DS_OBSERV")
        '      .DS_ESTADO = DbNullToInt32(Fila, "DS_ESTADO")
        '      .ES_NOMBRE = DbNullToString(Fila, "ES_NOMBRE")
        '      .SOL_NOMBRE = DbNullToString(Fila, "SOL_NOMBRE")
        '      .SXT_TICKET = DbNullToLong(Fila, "SXT_TICKET")
        '    End With
        '    Return obj
        '  Catch ex As Exception
        '    Throw ex
        '  Finally
        '    obj = Nothing
        '  End Try
        'End Function
#End Region

  End Class
End Namespace